Texture2D texture : register( t0 );
SamplerState colorSampler : register( s0 );

cbuffer cbChangesEveryFrame : register( b0 )
{
    matrix worldMatrix;
};

cbuffer cbNeverChanges : register( b1 )
{
    matrix viewMatrix;
};

cbuffer cbChangeOnResize : register( b2 )
{
    matrix projMatrix;
};

struct VSInputColor
{
	float4 pos		: POSITION;
	float4 color	: COLOR;
};

struct PSInputColor
{
	float4 pos		: POSITION;
	float4 color	: COLOR;
};

struct VSInputTexture
{
	float4 pos		: POSITION;
	float2 tex0 : TEXCOORD0;
};

struct PSInputTexture
{
	float4 pos		: POSITION;
	float2 tex0 : TEXCOORD0;
};

PSInputColor VSNoCameraNoTexture(VSInputColor vertex)
{
	return vertex;
}

PSInputColor VSWithCameraNoTexture(VSInputColor vertex)
{
	PSInputColor vsOut = ( PSInputColor )0;
    vsOut.pos = mul( vertex.pos, worldMatrix );
    vsOut.pos = mul( vsOut.pos, viewMatrix );
    vsOut.pos = mul( vsOut.pos, projMatrix );
	vsOut.color = vertex.color;
	return vsOut;
}

PSInputTexture VSNoCameraWithTexture(VSInputTexture vertex)
{
	return vertex;
}

PSInputTexture VSWithCameraWithTexture(VSInputTexture vertex)
{
	PSInputColor vsOut = ( PSInputTexture )0;
    vsOut.pos = mul( vertex.pos, worldMatrix );
    vsOut.pos = mul( vsOut.pos, viewMatrix );
    vsOut.pos = mul( vsOut.pos, projMatrix );
	vsOut.tex0 = vertex.tex0;
	return vsOut;
}

float4 PSNoTexture(PSInputColor frag) : SV_TARGET
{
	return frag.color;
}

float4 PSWithTexture(PSInputColor frag) : SV_TARGET
{
    float4 col = texture.Sample( colorSampler, frag.tex0 );
	return col;
}

technique11 DefaultTechniqueNoCameraNoTexture
{
	pass P0
	{
		SetVertexShader( CompileShader( vs_5_0, VSNoCameraNoTexture()));
		SetGeometryShader( NULL);
		SetPixelShader( CompileShader( ps_5_0, PSNoTexture()));
	}
}

technique11 DefaultTechniqueWithCameraNoTexture
{
	pass P0
	{
		SetVertexShader( CompileShader( vs_5_0, VSWithCameraNoTexture()));
		SetGeometryShader( NULL);
		SetPixelShader( CompileShader( ps_5_0, PSNoTexture()));
	}
}

technique11 DefaultTechniqueNoCameraWithTexture
{
	pass P0
	{
		SetVertexShader( CompileShader( vs_5_0, VSNoCameraWithTexture()));
		SetGeometryShader( NULL);
		SetPixelShader( CompileShader( ps_5_0, PSWithTexture()));
	}
}

technique11 DefaultTechniqueWithCameraWithTexture
{
	pass P0
	{
		SetVertexShader( CompileShader( vs_5_0, VSWithCameraWithTexture()));
		SetGeometryShader( NULL);
		SetPixelShader( CompileShader( ps_5_0, PSWithTexture()));
	}
}